package com.leetcode.problems046;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode-cn.com/problems/jump-game-ii/
 * @Date 2021/12/09 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution {
    List<List<Integer>> ans = new ArrayList<>();

    public List<List<Integer>> permute(int[] nums) {
        permute(nums,new boolean[nums.length],new ArrayList<>());

        return ans;
    }
    public void permute(int[] nums,boolean[] used,List<Integer> res) {
        if(res.size() == nums.length){
            ans.add(new ArrayList<Integer>(res));
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            if(!used[i]) {
                res.add(nums[i]);
                used[i] = true;
                permute(nums, used, res);
                used[i] = false;
                res.remove(res.size() - 1);
            }
        }
    }


    public static void main(String[] args) {
        int[] candidates = {1};
        System.out.println(new Solution().permute(candidates));
    }
}
